package com.socialuni.center.web.factory;

import com.socialuni.center.web.model.EO.TalkEO;
import com.socialuni.sdk.model.DO.talk.TalkDO;
import com.socialuni.sdk.repository.TalkRepository;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TalkEOFactory {
    static TalkRepository talkRepository;

    @Resource
    public void setTalkRepository(TalkRepository talkRepository) {
        TalkEOFactory.talkRepository = talkRepository;
    }


    public static TalkEO newTalkEOFactory(Integer talkId) {
        TalkDO talkDO = talkRepository.findOneById(talkId);

        TalkEO talkEO = new TalkEO();
        //content
        talkEO.setId(talkDO.getId());
        talkEO.setUserId(talkDO.getUserId());
        talkEO.setContent(talkDO.getContent());
        talkEO.setHugNum(talkDO.getHugNum());
        talkEO.setCommentNum(talkDO.getCommentNum());
        talkEO.setGlobalTop(talkDO.getGlobalTop());
        talkEO.setUpdateTime(talkDO.getUpdateTime());
        //thirdContent
        talkEO.setDevId(talkDO.getDevId());
        //talkDO
//        talkEO.setVisibleType(talkDO.getVisibleType());
        talkEO.setVisibleGender(talkDO.getVisibleGender());
        talkEO.setAdName(talkDO.getAdName());
        talkEO.setProvinceName(talkDO.getProvinceName());
        talkEO.setCityName(talkDO.getCityName());
        talkEO.setDistrictName(talkDO.getDistrictName());
        talkEO.setLon(talkDO.getLon());
        talkEO.setLat(talkDO.getLat());
        return talkEO;
    }

}
